const mongoose = require('mongoose')

// 连接 MongoDB 
mongoose.connect('mongodb+srv://3304712157:itempassword@cluster0.h82oi.mongodb.net/').then(()=>{
    console.log('数据库连接成功')
}).catch(()=>{
    console.log('数据库连接失败')
})

// 创建集合规则
const listSchema = new mongoose.Schema({
    name:String,
    img:String,
    xprice:Number,
    yprice:Number,
    yishou:Number
})
const listModel = mongoose.model('list',listSchema)
//体检套餐
const qjxtijianSchema = new mongoose.Schema({
    dateTime:String,
    hospital:String,
    address:String,
    distance:String,
    department:String,
    doctor:String,
    patient:String,
    visitDate:String,
    amount:Number,
    paymentMethod:String
});
const qjxtijianModel = mongoose.model('qjxtijian', qjxtijianSchema);
//挂号
const qjxguahaoSchema = new mongoose.Schema({
            title: String,
            subTitle:String,
            description:String,
            price:String,
            timeLeft: String,
            cate:{
                type:mongoose.Schema.Types.ObjectId,
                ref:'qjxcate'
            }
})
const qjxguahaoModel = mongoose.model('qjxguahao', qjxguahaoSchema);
const qjxcateSchema = new mongoose.Schema({
   name:String, 
})
const qjxcateModel = mongoose.model('qjxcate', qjxcateSchema);
//我的问诊
const qjxwenzhenSchema = new mongoose.Schema({
    title:String,
    zhiye:String,
    zhifu:String,
    neirong:String,
    time:String,
    yvyue:String,
    cate:{
        type:mongoose.Schema.Types.ObjectId,
        ref:'qjxcatees'
    }
})
const qjxwenzhenModel = mongoose.model('qjxwenzhen', qjxwenzhenSchema);
const qjxcateesSchema = new mongoose.Schema({
    name:String
})
const qjxcateesModel = mongoose.model('qjxcatees', qjxcateesSchema);
//俯卧撑目标
const qjxfuSchema = new mongoose.Schema({
    stepValue:Number
})
const qjxfuModel = mongoose.model('qjxfu', qjxfuSchema);
const qjxzouSchema = new mongoose.Schema({
    stepValue:Number
})
const qjxzouModel = mongoose.model('qjxzou', qjxzouSchema);
const qjxshenSchema = new mongoose.Schema({
    stepValue:Number
})
const qjxshenModel = mongoose.model('qjxshen', qjxshenSchema);
const qjxyangSchema = new mongoose.Schema({
    stepValue:Number
})
const qjxyangModel = mongoose.model('qjxyang', qjxyangSchema);
//地址管理
const addressSchema = new mongoose.Schema({
  phone:String,
  sheng:String,
  shi:String,
  qu:String,
  adress:String,
  mo:String,
})
const addressModel = mongoose.model('address', addressSchema);
module.exports = {
    listModel,
    qjxtijianModel,
    qjxguahaoModel,
    qjxcateModel,
    qjxwenzhenModel,
    qjxcateesModel,
    qjxfuModel,
    qjxzouModel,
    qjxshenModel,
    qjxyangModel,
    addressModel
}